package com.hadoop.sxtmr;

import org.apache.hadoop.io.WritableComparable;
import org.apache.hadoop.io.WritableComparator;

public class SortHot extends WritableComparator{
	
	public SortHot(){
		super(KeyPair.class,true);
	}
	/**
	 * 按年份升序，按温度降序
	 */
	@Override
	public int compare(WritableComparable a, WritableComparable b) {
		System.out.println("sorthot.class");
		KeyPair o1 = (KeyPair) a;
		KeyPair o2 = (KeyPair) b;
		int res = Integer.compare(o1.getYear(), o2.getYear());
		if(res != 0){
			return res;
		} else {
			return Integer.compare(o1.getHot(), o2.getHot());
		}
	}

	
}
